package com.ruoyi.web.controller.picture;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.picture.domain.Fam;
import com.ruoyi.picture.domain.Pauser;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.picture.domain.Acictures;
import com.ruoyi.picture.service.IAcicturesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 相册管理Controller
 * 
 * @author ruoyi
 * @date 2024-01-15
 */
@RestController
@RequestMapping("/picture/acpictures")
public class AcicturesController extends BaseController
{
    @Autowired
    private IAcicturesService acicturesService;


    @PostMapping("/insertlist")
    public AjaxResult insertlist(@RequestBody Fam fam)
    {
        int a = acicturesService.insertlist(fam);
        return success(a);
    }


    @GetMapping("/userlist")
    public TableDataInfo userlist(String id,String status)
    {
        startPage();
        Acictures acictures = new Acictures();
        acictures.setId(Long.valueOf(id));
        acictures.setStatus(status);
        List<Pauser> list = acicturesService.userlist(acictures);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('picture:acpictures:list')")
    @GetMapping("/list")
    public TableDataInfo list(Acictures acictures)
    {
        startPage();
        List<Acictures> list = acicturesService.selectAcicturesList(acictures);
        return getDataTable(list);
    }

    /**
     * 导出相册管理列表
     */
    @PreAuthorize("@ss.hasPermi('picture:acpictures:export')")
    @Log(title = "相册管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Acictures acictures)
    {
        List<Acictures> list = acicturesService.selectAcicturesList(acictures);
        ExcelUtil<Acictures> util = new ExcelUtil<Acictures>(Acictures.class);
        util.exportExcel(response, list, "相册管理数据");
    }

    /**
     * 获取相册管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('picture:acpictures:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(acicturesService.selectAcicturesById(id));
    }

    /**
     * 新增相册管理
     */
    @PreAuthorize("@ss.hasPermi('picture:acpictures:add')")
    @Log(title = "相册管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Acictures acictures)
    {
        return toAjax(acicturesService.insertAcictures(acictures));
    }

    /**
     * 修改相册管理
     */
    @PreAuthorize("@ss.hasPermi('picture:acpictures:edit')")
    @Log(title = "相册管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Acictures acictures)
    {
        return toAjax(acicturesService.updateAcictures(acictures));
    }

    /**
     * 删除相册管理
     */
    @PreAuthorize("@ss.hasPermi('picture:acpictures:remove')")
    @Log(title = "相册管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(acicturesService.deleteAcicturesByIds(ids));
    }
}
